import axios from '@/utils/request'
// 获取验证码
function apiGetCode (mobile) {
  return axios({
    url: '/au/code',
    method: 'post',
    data: {
      mobile
    }
  })
}
// 登录
function apiLogin ({ mobile, code }) {
  return axios({
    url: '/au/login',
    method: 'post',
    data: {
      mobile,
      code
    }
  })
}
// 用户信息
function apiGetInfo () {
  return axios({
    url: '/au/info',
    method: 'get',
    needToken: true
  })
}
// 编辑用户信息
function apiEditInfo ({ nickname, intro, gender, avatar, position, area }) {
  return axios({
    url: '/au/edit',
    method: 'post',
    needToken: true,
    data: {
      nickname,
      intro,
      gender,
      avatar,
      position,
      area
    }
  })
}
// 文件上传
function apiUpload (files) {
  const fd = new FormData()
  fd.append('files', files)
  return axios({
    url: '/upload',
    method: 'post',
    needToken: true,
    data: fd
  })
}

export { apiGetCode, apiLogin, apiGetInfo, apiEditInfo, apiUpload }
